﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmTemplates.aspx.cs" Inherits="WCrawler.frmTemplates" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
<%@ Register Src="~/Controls/ucTemplate.ascx" TagName="ucTemplate" TagPrefix="UserControl" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <h2>
        <asp:HyperLink ID="forumUrl" runat="server">HyperLink</asp:HyperLink>
    </h2>
    
    <asp:Label ID="Label6" runat="server" Text="Forum Type"></asp:Label>
    <asp:DropDownList ID="dropDownListForumType" runat="server" 
        DataSourceID="ForumTypeLinqDataSource" DataTextField="TypeName" 
        DataValueField="ForumTypeId" AutoPostBack="True" 
        onselectedindexchanged="dropDownListForumType_SelectedIndexChanged">
    </asp:DropDownList>
    
    <table style="width:100%;">
        <tr>
            <td valign="top">
                <asp:PlaceHolder runat="server" ID="Body">
                <UserControl:ucTemplate id="ucTemplate" runat="server" OnSeletedTemplateIndexChanged="ucTreeViewTemplate_SelectedIndexChanged"/>
            </asp:PlaceHolder> 
                </td>
            <td valign="top">
        <div>
        <asp:GridView ID="gridViewTemplateDetails" runat="server" 
            AutoGenerateColumns="False" DataKeyNames="TemplateDetailsId" 
            DataSourceID="TemplateDetailsLinqDataSource" Width="100%" 
            BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
            CellPadding="4" AllowSorting="True">
            <EmptyDataTemplate>
                <asp:Label ID="lblEmptySearch" runat="server" Font-Bold="True" ForeColor="#0033CC">No Results Found....  
                </asp:Label>
            </EmptyDataTemplate>
            <Columns>
                <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
                <asp:BoundField DataField="TemplateDetailsId" HeaderText="Id" ReadOnly="true"
                    SortExpression="TemplateDetailsId"/>
                <asp:TemplateField HeaderText = "Template" SortExpression="Template.TemplateName">
                    <ItemTemplate>
                        <asp:Label ID="lblTemplate" runat="server" Text='<%#Bind("Template.TemplateName")%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <%--<asp:BoundField DataField="TemplatePattern" HeaderText="Pattern"
                    SortExpression="TemplatePattern">
                </asp:BoundField>--%>
                <asp:TemplateField HeaderText = "Pattern">
                    <ItemTemplate>
                        <asp:Label ID="lblTemplatePattern" runat="server" Text='<%#Bind("TemplatePattern")%>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtTemplatePattern" runat="server" Text='<%#Bind("TemplatePattern")%>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField DataField="IsDefault" HeaderText="IsDefault"
                    SortExpression="IsDefault"/>
                <%--<asp:TemplateField HeaderText = "Default">
                    <ItemTemplate>
                        <asp:CheckBox ID="chkIsDefault" runat="server" AutoPostBack="true" Checked='<%#Eval("IsDefault")%>'></asp:CheckBox>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:CheckBox ID="chkIsDefault" runat="server" AutoPostBack="true" Checked='<%#Eval("IsDefault")%>'></asp:CheckBox>
                    </EditItemTemplate>
                </asp:TemplateField>--%>
            </Columns>
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <RowStyle BackColor="White" ForeColor="#003399" />
            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
            <SortedAscendingCellStyle BackColor="#EDF6F6" />
            <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
            <SortedDescendingCellStyle BackColor="#D6DFDF" />
            <SortedDescendingHeaderStyle BackColor="#002876" />
        </asp:GridView>
        </div>
        <div>
    <asp:Button ID="btnAddDetailsTemplate" runat="server" onclick="btnAddDetailsTemplate_Click" 
        Text="Add Details Template" />
        </div>
            </td>
        </tr>
    </table>

        <asp:LinqDataSource ID="TemplateDetailsLinqDataSource" runat="server" 
            ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
            TableName="TemplateDetails" 
        onselecting="TemplateDetailsLinqDataSource_Selecting" EnableUpdate="True" 
        EnableDelete="True" OrderBy="TemplateId">
        </asp:LinqDataSource>
    <asp:LinqDataSource ID="ForumTypeLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="ForumTypes">
    </asp:LinqDataSource>

        <asp:LinqDataSource ID="ForumTemplateDetailsLinqDataSource" runat="server" 
            ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
            TableName="ForumTemplateDetails" EnableUpdate="True" 
        Where="ForumId == @ForumId" EnableDelete="True">
            <WhereParameters>
                <asp:QueryStringParameter Name="ForumId" QueryStringField="ForumId" 
                    Type="Int32" />
            </WhereParameters>
        </asp:LinqDataSource>
        
    <br />
    <div>
    <!-- Popup show full content-->
        <asp:Button ID="btnShowPopup" runat="server" style="display:none" />
        <ajaxToolkit:ModalPopupExtender id="mdlPopup" runat="server" 
            backgroundcssclass="BackgroundStyle" popupcontrolid="PanelDetailsTemplate" 
            targetcontrolid="btnShowPopup">
        </ajaxToolkit:ModalPopupExtender>
        <asp:Panel ID="PanelDetailsTemplate" runat="server" BackColor="#ffffff" 
            BorderColor="#dadada" BorderStyle="Solid" BorderWidth="4px" Font-Names="Arial" 
            Font-Size="10pt" Width="800px">
            <table cellpadding="10" cellspacing="0" style="width: 100%">
                <tr>
                    <td>
                        <asp:Label ID="Label8" runat="server" Text="Add New Pattern"></asp:Label>
                        <asp:TextBox ID="txtTemplatePattern" runat="server" Width="607px"></asp:TextBox>
                        <asp:CheckBox ID="chkDefault" runat="server" Checked="True" Text="Default" />
                    </td>
                </tr>
                <tr>
                    <td align="center" valign="middle">
                        <asp:Button ID="btnAdd" runat="server" onclick="btnSend_Click" Text="Add" />
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                        <br />
                        <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
        
    </asp:Content>
